﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfPdfReader
{
    /// <summary>
    /// LabMainButtonControl.xaml 的交互逻辑
    /// </summary>
    public partial class LabMainButtonControl : UserControl
    {
        //public static readonly DependencyProperty ContentLabelProperty;
        public static readonly DependencyProperty NormalBackgroundProperty;
        public static readonly DependencyProperty PressedBackgroundProperty;
        //public object ContentLabel
        //{
        //    get { return GetValue(ContentLabelProperty); }
        //    set { SetValue(ContentLabelProperty, value); }
        //}
        public Brush NormalBackground
        {
            get { return GetValue(NormalBackgroundProperty) as Brush; }
            set
            {
                SetValue(NormalBackgroundProperty, value);
                this.Background = value;
            }
        }
        public Brush PressedBackground
        {
            get { return GetValue(PressedBackgroundProperty) as Brush; }
            set
            {
                SetValue(PressedBackgroundProperty, value);
                this.Background = value;
            }
        }
        static LabMainButtonControl()
        {
            //ContentLabelProperty = DependencyProperty.Register("ContentLabel", typeof(object), typeof(LabMainButtonControl));
            NormalBackgroundProperty = DependencyProperty.Register("NormalBackground", typeof(Brush), typeof(LabMainButtonControl));
            PressedBackgroundProperty = DependencyProperty.Register("PressedBackground", typeof(Brush), typeof(LabMainButtonControl));
        }
        public LabMainButtonControl()
        {
            InitializeComponent();
        }

        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            //this.Background = BrushHelper.GetBrush(new Uri("Images/midbutton2.png", UriKind.Relative));
            this.Background = this.PressedBackground;
            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            //this.Background = BrushHelper.GetBrush(new Uri("Images/midbutton.png", UriKind.Relative));
            this.Background = this.NormalBackground;
            base.OnMouseUp(e);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            //if (ContentLabel == null)
            //    this.Label.Content = this.Name;
            //else
            //    this.Label.Content = ContentLabel;
            this.Background = this.NormalBackground;
        }
    }
}
